<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>组织机构管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <link rel="stylesheet" src="/web/res/lib/layui/css/layui.css"></link>
    <script src="/web/res/lib/layui/layui.js"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>

    <link rel="stylesheet" href="/web/res/dtree/dtree.css" type="text/css">
    <script type="text/javascript" src="/web/res/dtree/dtree.js"></script>

    <script>
        function edit(id){
            var page = document.getElementsByTagName('iframe');
            page[0].src = "/organ/detail?id="+ id;
        }
        function freshref(id) {
            // alert(id);
            layui.use('layer',function () {
                ajaxPost(layui.$,"/organ/left",{"defaultId":id},function (data) {
                    if (data.code == 0) {
                        var list = data.data.list;
                        root = new dTree("root", "tree");
                        root.config.folderLinks=true;
                        root.config.closeSameLevel=true;
                        for(var organ in list){
                            root.add(list[organ].id, list[organ].pid,list[organ].title,'javascript:edit('+list[organ].id+')','','','','/web/res/dtree/img/folderopen.gif','false');
                        }
                        root.draw();
                        edit(data.data.defaultId);
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 1000}, function(){
                        });
                    }
                });
            });
        }
    </script>
</head>

<body>


<div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">系统管理</a>
            <a><cite>组织机构管理</cite></a>
        </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div id="tree" class="dtree"></div>
<div class="page-content" style="top: 0;box-shadow: 0 0 5px lightgray;">
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <iframe src='' frameborder="0" scrolling="yes" class="x-iframe" id="cont"></iframe>
        </div>
    </div>
</div>
<script>
    var root = new dTree("root", "tree");
    root.config.folderLinks=true;
    root.config.closeSameLevel=true;
    freshref();
</script>
</body>
</html>